//
//  WSGTabBar.m
//  oneDollar
//
//  Created by Laki on 16/6/15.
//  Copyright © 2016年 com.Laki.corder. All rights reserved.
//

#import "WSGTabBar.h"

@implementation WSGTabBar

#pragma mark --------------------
#pragma mark 布局TabBarItem子控件里面的Frame
- (void)layoutSubviews{
    [super layoutSubviews];
    // 计算出有多少个按钮
    NSInteger count = self.items.count;

    // 设置Frame属性
    CGFloat itemX = 0;
    CGFloat itemY = 7;
    CGFloat itemW = self.bounds.size.width / count;
    CGFloat itemH = self.bounds.size.height;
    NSInteger index = 0;
    
    // 遍历取出每个按钮进行设置
    for (UIControl *btn in self.subviews) {
        // 过滤
        if ([btn isKindOfClass:NSClassFromString(@"UITabBarButton")]) {
            itemX = index * itemW;
            btn.frame = CGRectMake(itemX, itemY, itemW, itemH);
            index++;
        }
    }
}

@end
